$("#table").bootstrapTable({
    url: '/room/getAllRoomType',
    contentType: 'application/x-www-form-urlencoded',
    method: 'POST',
    toolbar: '#toolbar',
    sidePagination: 'server',
    pageNumber: 1,//当前页
    pageSize: 15,//每页条数
    pageList: [15, 50, 100, 'ALL'],
    dataType: 'json',//返回数据的类型
    /*detailView: true,*/
    cache: false,
    pagination: false,//使用分页
    /*showRefresh: true,//右上角刷新按钮
    showColumns: true,//右上角,列,列表*/
    // queryParams:function (params) {
    //     params["parentId"] = $("#parent-select").val();
    //     return params;
    // },
    classes: 'table table-hover table-striped',
    columns: [{
        checkbox: true
    }, {
        field: 'number',
        title: '序号',
        align: 'center',
        formatter: function (value, row, index) {
            return (index + 1);
        }
    }, {
        field: "id",
        title: "房间类型编号",
        align: "center"
    }, {
        field: "name",
        title: "房间类型名称",
        align: "center"
    }, {
        field: "descriptor",
        title: "房间类型描述",
        align: "center"
    }, {
        field: "operator",
        title: "操作",
        align: "center",
        formatter: function (value, row, index) {
            var str = "<span class='glyphicon glyphicon-pencil' onclick='changePrivilege(" + row.id + ")'></span>&nbsp&nbsp;" +
                "<span class='glyphicon glyphicon-trash' onclick='delPrivilegeById(" + row.id + ")'></span>&nbsp&nbsp;";

            return str;
        }
    }]
});

/**
 * 添加房间类型信息
 */
function addroomtype() {
    $("#addroomtypeModal").modal("show");
    $("#addroomtypeModal .modal-body").load("/room/openAddRoomTypeJsp");
}

/**
 * 添加退房信息提交
 */
function addRoomTypeSubmit() {
    $.post("/room/AddRoomType",
        {
            "name": $("#name").val(),
            "descriptor": $("#descriptor").val()
        }, function (data) {
            if (data.result>0) {
                $("#table").bootstrapTable('refresh');
                swal('添加成功!', '信息添加成功!', 'success');
                $("#addroomtypeModal").modal('hide');
            } else {
                swal('添加失败!', '信息添加失败!', 'error');
                $("#addroomtypeModal").modal('hide');
            }
        }, "json"
    );
}
